import { createApp } from "vue";
import pinia from "./stores";
import ElementPlus from "element-plus";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import "element-plus/dist/index.css";
import App from "./App.vue";
import router from "./router";
import "./styles/index.scss";
import ElSvg from "./components/SvgIcon/ElSvg";
import "./permission";
// 引入这个组件
import Category from "@/components/Category/index.vue";
import { useUserInfoStore } from "@/stores/userInfo";
//引入VueEcharts插件
import {VueEcharts} from "./plugins/echarts"

 import "@/mockServer";

 const userInfoStore = useUserInfoStore(pinia)
const app = createApp(App);

ElSvg(app);

// 全局注册三级联动组件
app.component("Category",Category);

app.directive("has", (el, binding) => {
  //el是按当前绑定自定义指令的DOM
  //binding是当前自定义指令的值
  // console.log(binding);

  if (!userInfoStore.userInfo.buttons.includes(binding.value)) {
    el.remove();
  }
});

app
  .use(pinia)
  .use(router)
  .use(VueEcharts)
  .use(ElementPlus, {
    locale: zhCn,
  })
  .mount("#app");
